package com.jpcc.vw.onlineRadio.adapter.item;

import android.content.Intent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.jpcc.vw.onlineRadio.R;
import com.jpcc.vw.onlineRadio.activity.CategoryTagActivity;
import com.jpcc.vw.onlineRadio.model.bean.AlbumCategoryEntity;
import com.jpcc.vw.onlineRadio.recycle.RecyclerView.BaseItem;

public class AlbumCategoryItem extends BaseItem<AlbumCategoryEntity> implements View.OnClickListener {

    private AlbumCategoryEntity entity;
    private TextView tv_category;
    private TextView tv_position;
    private ImageView imv_cover;

    public AlbumCategoryItem(ViewGroup parent) {
        super(parent);
    }

    @Override
    public int getRes() {
        return R.layout.adapter_album_category;
    }

    @Override
    public void onCreateView(View rootView) {
        tv_category=(TextView)rootView.findViewById(R.id.tv_category);
        tv_position=(TextView)rootView.findViewById(R.id.tv_position);
        imv_cover=(ImageView)rootView.findViewById(R.id.imv_cover);
    }

    @Override
    public void onBindView(AlbumCategoryEntity albumCategoryEntity) {
        entity=albumCategoryEntity;
        tv_category.setText(entity.getName());
        tv_position.setText(getPosition()+1+"");
        Glide.with(getContext()).load(entity.getCoverUrlSmall()).into(imv_cover);
    }

    @Override
    public void onClick(View v) {
        Intent intent=new Intent(getContext(),CategoryTagActivity.class);
        intent.putExtra("KEY_CATEGORY_ID",entity.getId());
        intent.putExtra("KEY_CATEGORY_NAME",entity.getName());
        getContext().startActivity(intent);
    }
}
